package com.cskaoyan.shopping.converter;

import com.cskaoyan.mall.dto.ProductDetailDto;
import com.cskaoyan.shopping.dal.entitys.Item;
import com.cskaoyan.shopping.dal.entitys.ItemDesc;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

@Mapper(componentModel = "spring")
public interface ItemConverter {

    @Mappings({
            @Mapping(source = "itemDesc.itemDesc", target = "detail"),
            @Mapping(source = "item.images", target = "productImageSmall"),
            @Mapping(source = "item.imageBig", target = "productImageBig"),
            @Mapping(source = "item.id", target = "productId"),
            @Mapping(source = "item.price", target = "salePrice"),
            @Mapping(source = "item.title", target = "productName"),
            @Mapping(source = "item.sell_point", target = "subTitle"),
            @Mapping(source = "item.limit_num", target = "limitNum"),
    }
    )
    ProductDetailDto itemToProductDetailDto(Item item, ItemDesc itemDesc);

}
